package com.mo.bio;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * BIO：阻塞式IO
 *
 */
public class ServerSocketTest {
    public static void main(String[] args) throws IOException {
        //telnet localhost 9000
        //ctrl+]
        //send 数据
        ServerSocket socket = new ServerSocket(9000);
        Socket accept = socket.accept();
        System.out.println("等待连接！");
        handler(accept);

    }

    static void handler(Socket accept) throws IOException {
        byte[] bytes = new byte[1024];
        int read = accept.getInputStream().read(bytes);
        while (read != -1) {
            System.out.println(new String(bytes, 0, read));
        }

    }

}
